<?php

/**
 * 
 */
class Register_model extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->database();
    }

    public function register() {
        $data['user_role_id'] = 2;
        $data['login'] = $this->input->post('login');
        $data['password'] = md5($this->input->post('pass'));
        $data['email'] = $this->input->post('email');

        $sql = "SELECT user_id FROM users where email='" . $data['email'] . "' OR login='" . $data['login'] . "'";
        $query = $this->db->query($sql);
        if ($query->num_rows() == 0) {
            $this->db->insert('users', $data);
        }
        //echo $query->num_rows();
        return $query->num_rows();
    }

}
?> 


